'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  
  async index() {
    try {
      const res = await this.ctx.curl('https://cnodejs.org/api/v1/topics', { dataType: 'json' });
      if (res.status !== 200) throw new Error('response status is not 200');
      this.ctx.body = res.data;
    } catch (err) {
      this.logger.error(err);
      return {};
    }

  }
}

module.exports = HomeController;
